//
//  ViewController.m
//  runTime
//
//  Created by SmartStrategy on 2020/4/9.
//  Copyright © 2020 SmartStrategy. All rights reserved.
//

#import "ViewController.h"
#import "Person.h"
#import "YangYang.h"
#import <objc/runtime.h>

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    Person *person = [[Person alloc] init];
    [person getName];
    
    unsigned  int count = 0;
        Ivar *members = class_copyIvarList([Person class], &count);
        
        for (int i = 0; i < count; i++)
        {
            Ivar var = members[i];
            const char *memberAddress = ivar_getName(var);
            const char *memberType = ivar_getTypeEncoding(var);
            NSLog(@"address = %s ; type = %s",memberAddress,memberType);
        }
    Ivar var = members[0];
    YangYang *yangyanng = [[YangYang alloc] init];
    yangyanng.name = @"3333";
    object_setIvar(person, var, yangyanng);
    [person getName];
   
    
}


@end
